<template>
  <basic-container>
    <basic-header title="商品一级分类" />
    <apply-table :action="action" :viewBtn="false" :deleteBtn="false">
      <template slot-scope="{ row }" slot="applyMenu">
        <el-button v-if="row.id !== 24" plain type="danger" size="small" icon="el-icon-delete" @click.stop="handleDelete(row)">删除</el-button>
      </template>
    </apply-table>
  </basic-container>
</template>
<script>
import ApplyTable from "@/components/ApplyTable";
import actionTypes from "@/const/action";
import { mapActions } from "vuex";
export default {
  name: "first",
  components: { ApplyTable },
  data() {
    return {
      action: actionTypes.GOODS_CATEGORY_FIRST
    };
  },
  methods: {
    ...mapActions("table", ["PromiseDeleteRow"]),
    handleDelete(row) {
      this.$confirm("确认删除吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        this.PromiseDeleteRow({
          action: this.action,
          id: row.id
        })
          .then(() => {
            this.$message({
              type: "success",
              message: "已成功删除"
            });
          })
          .catch(error => {
            this.$message({
              type: "error",
              message: error.message || String(error)
            });
          });
      });
    }
  }
};
</script>
<style lang="scss" scoped>
</style>

